use serde::{Deserialize, Serialize};

pub const EVENT_TYPE_SETUP: &str =
    "endpoint.traffic_steering_rule.te_policy_group.candidate_path/setup";
pub const EVENT_TYPE_DELETE: &str =
    "endpoint.traffic_steering_rule.te_policy_group.candidate_path/delete";

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SetupEventPayload {
    pub endpoint_id: String,
    pub traffic_steering_rule_id: String,
    pub te_policy_group_id: String,
    pub candidate_path_id: String,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct DeleteEventPayload {
    pub endpoint_id: String,
    pub traffic_steering_rule_id: String,
    pub te_policy_group_id: String,
    pub candidate_path_id: String,
}

pub type SetupEvent = wanmesh_common::dto::Event<SetupEventPayload>;
pub type DeleteEvent = wanmesh_common::dto::Event<DeleteEventPayload>;

pub fn new_setup_event(payload: SetupEventPayload) -> SetupEvent {
    SetupEvent {
        event_type: EVENT_TYPE_SETUP.to_string(),
        payload,
    }
}

pub fn new_delete_event(payload: DeleteEventPayload) -> DeleteEvent {
    DeleteEvent {
        event_type: EVENT_TYPE_DELETE.to_string(),
        payload,
    }
}
